export const amountCollect = ({ xAxis, series }) => {
  const list = series.map((i) => i / 100)
  return {
    title: {
      text: '销售趋势图',
      left: 'center'
    },
    tooltip: {
      show: true,
      trigger: 'axis',
      formatter: '销售额：{c}<br/>{MM}'
    },
    xAxis: {
      type: 'time',
      minInterval: 1
    },
    yAxis: {
      type: 'value',
      name: '单位：元'
    },
    dataset: {
      source: {
        time: xAxis || [
          '2022-11-14',
          '2022-11-15',
          '2022-11-16',
          '2022-11-17',
          '2022-11-18'
        ],
        value: list || [3170.44, 6152.62, 1660.76, 3695.8, 0]
      }
    },
    series: [
      {
        type: 'line',
        smooth: true,
        itemStyle: {
          color: '#d67b78'
        },
        lineStyle: {
          color: '#ff5757'
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              { offset: 0, color: '#ff575788' },
              { offset: 0.3, color: '#ff575720' },
              { offset: 1, color: '#ff575700' }
            ],
            global: false
          }
        },
        tooltip: ''
      }
    ]
  }
}
export const regionCollect = ({ xAxis, series }) => {
  const list = series.map((i) => i / 100)
  return {
    title: {
      text: '销售额分布图',
      left: 'center'
    },
    tooltip: {
      show: true,
      formatter: '销售额：{c}<br/>{b}'
    },
    xAxis: {
      type: 'category',
      data: xAxis || ['北京平西府街道', '霍营街道']
    },
    yAxis: {
      type: 'value',
      name: '单位：元'
    },
    series: [
      {
        data: list || [9671.74, 1837.44],
        type: 'bar',
        barWidth: 24,
        itemStyle: {
          color: '#91a9ff',
          borderRadius: [8, 8, 0, 0]
        }
      }
    ]
  }
}

export const ChartOpt = (item) => {
  return {
    tooltip: {
      formatter: '{b}<br/>总占比：{d}%'
    },
    color: ['#859fff', '#75f2bf', '#ffad83', '#bdebff', '#bccbe7'],
    series: [
      {
        type: 'pie',
        radius: ['30%', '60%'],
        roseType: 'radius',
        label: {
          formatter: '{b}\n{d}%'
        },
        data: item || [
          { value: 5, name: 'A' },
          { value: 3, name: 'b' },
          { value: 2, name: 'C' },
          { value: 1, name: 'D' },
          { value: 1, name: 'E' }
        ]
      }
    ]
  }
}
